/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utility.com;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 *
 * @author Yusup Jauhari Shandi <in.visi>
 */
public class Md5 {
    public static String setMd5(String param) {
        byte[] defaultBytes = param.getBytes();
            try{
                MessageDigest algorithm = MessageDigest.getInstance("MD5");
                algorithm.reset();
                algorithm.update(defaultBytes);
                byte messageDigest[] = algorithm.digest();

                StringBuffer hexString = new StringBuffer();
                for (int i=0;i<messageDigest.length;i++) {
                        hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
                }
                //String foo = messageDigest.toString();
                //System.out.println("sessionid "+passwd+" md5 version is "+hexString.toString());
                param=hexString+"";
            }catch(NoSuchAlgorithmException nsae){

            }
        
        return  param;
    }
}
